package com.rh.bmw4s.adapter;

import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.rh.bmw4s.R;
import com.rh.bmw4s.bean.BrandBean;

/**
 * Created by Administrator on 2017/9/27.
 */

public class GridAdapter extends ListBaseAdapter<BrandBean.BrandsBean> {
    Context context;

    public GridAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_category_grid;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        final BrandBean.BrandsBean bean = getDataList().get(position);
        LinearLayout linearLayout = holder.getView(R.id.ll_hotcartype);
        ImageView imgHead = holder.getView(R.id.img_head);
        Glide.with(context).load(bean.getLogo()).placeholder(R.mipmap.logo).into(imgHead);
        TextView tvName = holder.getView(R.id.tv_name);
        tvName.setText(bean.getModel_name());
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                hotCarTypeItemListener.onHotTypeItemListener(bean.getId());
            }
        });
    }

    public interface HotCarTypeItemListener {
        void onHotTypeItemListener(int id);
    }

    HotCarTypeItemListener hotCarTypeItemListener;

    public void setHotCarTypeItemListener(HotCarTypeItemListener hotCarTypeItemListener) {
        this.hotCarTypeItemListener = hotCarTypeItemListener;
    }
}
